---
title: Wikipedia Reader (Async)
---

The **Wikipedia Reader** with asynchronous processing allows you to search and read Wikipedia articles efficiently, converting them into vector embeddings for your knowledge base.

## Code

```python examples/concepts/knowledge/readers/wikipedia_reader_async.py
import asyncio

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.arxiv_reader import ArxivReader
from agno.knowledge.reader.wikipedia_reader import WikipediaReader
from agno.vectordb.pgvector import PgVector

# Create Knowledge Instance
knowledge = Knowledge(
    name="Multi-Source Knowledge Base",
    description="Knowledge base combining Wikipedia and ArXiv content",
    vector_db=PgVector(
        table_name="multi_vectors", 
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai"
    ),
)

async def main():
    # Add topics from Wikipedia
    await knowledge.add_content_async(
        metadata={"source": "wikipedia", "type": "encyclopedia"},
        topics=["Manchester United", "Machine Learning"],
        reader=WikipediaReader(),
    )

    # Add topics from ArXiv
    await knowledge.add_content_async(
        metadata={"source": "arxiv", "type": "academic"},
        topics=["Carbon Dioxide", "Neural Networks"],
        reader=ArxivReader(),
    )

    # Create an agent with the knowledge
    agent = Agent(
        knowledge=knowledge,
        search_knowledge=True,
    )

    # Query the knowledge base
    await agent.aprint_response(
        "What can you tell me about Machine Learning from both general and academic sources?",
        markdown=True
    )

if __name__ == "__main__":
    asyncio.run(main())
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install libraries">
    ```bash
    pip install -U wikipedia arxiv sqlalchemy psycopg pgvector agno openai
    ```
  </Step>

  <Step title="Set environment variables">
    ```bash
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Snippet file="run-pgvector-step.mdx" />

  <Step title="Run Agent">
    <CodeGroup>
    ```bash Mac
    python examples/concepts/knowledge/readers/wikipedia_reader_async.py
    ```

    ```bash Windows
    python examples/concepts/knowledge/readers/wikipedia_reader_async.py
    ```
    </CodeGroup>
  </Step>
</Steps>

## Params

<Snippet file="wikipedia-reader-reference.mdx" />
